package javaExer;

import java.util.Scanner;

public class ArrayTest {

    public static void main(String[] aRrgs) {

        //创建一个类MyTools，编写一个方阿飞，可以完成对int数组冒泡排序
        class MyTools {

            public void bubble(int[] arr) {
                //冒泡排序
                for (int i = 0; i < arr.length - 1; i++) { //外层循环次数 arr.length -1
                    for (int j = 0; j < arr.length - 1 -i ; j++) {
                        if (arr[j] < arr[j + 1]) { //交换
                            int temp = arr[j];
                            arr[j] = arr[j + 1];
                            arr[j + 1] = temp;
                        }
                    }
                }
            }
        }

        /*class Person{
            String name;

            public Person(String name) {
                this.name = name;
            }
        }
*/
        Scanner myScanner = new Scanner(System.in);

        MyTools tool = new MyTools();
        int arr[] = {2, 5, 7, 1, 213};
        tool.bubble(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + "  ");
        }
    }
}
